package com.sleep.psy.external_server.business.resourse.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sleep.psy.external_server.business.resourse.entity.ResourceAudio;
import com.sleep.psy.external_server.business.resourse.mapper.ResourceAudioMapper;
import com.sleep.psy.external_server.business.resourse.service.ResourceAudioService;
import com.sleep.psy.external_server.constants.MySqlConstant;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 音频碎片表 服务实现类
 * </p>
 *
 * @author wenliguo
 * @since 2025-08-12
 */
@Service
public class ResourceAudioServiceImpl extends ServiceImpl<ResourceAudioMapper, ResourceAudio> implements ResourceAudioService {

    @Autowired
    private ResourceAudioMapper resourceAudioMapper;

    /**
     * 通过code获取有效音频碎屏
     * @author wenliguo
     * @date 2025/6/10 11:10
     * @param code code码
     * @return com.sleep.psy.main_server.business2.scale.entity.ResourceAudio
     */
    @Override
    public ResourceAudio selectAudioByCode(String code) {

        QueryWrapper<ResourceAudio> wrapper = new QueryWrapper<>();
        wrapper.eq("code", code)
                .eq("status", MySqlConstant.STATUS_1);
        return resourceAudioMapper.selectOne(wrapper);
    }
}
